import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';

import { IndexPageComponent } from './businesses/index-page/index-page.component';
import { InfoShowComponent } from './businesses/info-show/info-show.component';
import { InfoAddFormComponent } from './businesses/info-add-form/info-add-form.component';
import { InfoUpdateFormComponent } from './businesses/info-update-form/info-update-form.component';

import { UnsaveGuard } from './guard/unsave.guard';
import { AccessGuard } from './guard/access.guard';

import { PipePracticeComponent } from './businesses/practice/pipe-practice/pipe-practice.component';
import { MoodComponent } from './businesses/practice/mood/mood.component';
import { MapComponent } from './businesses/practice/map/map.component';
import { StopwatchComponent } from './businesses/practice/stopwatch/stopwatch.component';
import { AppComponent } from './app.component';
import { AddAccessGuard } from './guard/add-access.guard';


const routes: Routes = [
      { path: '', redirectTo: '/index-page', pathMatch: 'full' },
      { path: 'index-page', component: IndexPageComponent },
      { path: 'show-info', component: InfoShowComponent, canActivate: [AccessGuard] },
      { path: 'add-info', component: InfoAddFormComponent, canActivate: [AddAccessGuard] },
      { path: 'update-info', component: InfoUpdateFormComponent, canActivate: [AccessGuard], canDeactivate: [UnsaveGuard] },
      { path: 'money-convert', component: PipePracticeComponent, canActivate: [AccessGuard] },
      { path: 'mood', component: MoodComponent, canActivate: [AccessGuard] },
      { path: 'stopwatch', component: StopwatchComponent, canActivate: [AccessGuard] },
      { path: 'map', component: MapComponent, canActivate: [AccessGuard] },
      { path: '**', redirectTo: '/index-page' },
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule],
  providers: [AccessGuard, UnsaveGuard, AddAccessGuard]
})
export class AppRoutingModule { }
